function BattleSpecialMageWhite()
{
RenderMap();

  BattleName(); 
  DrawPlayerStats();
  
  var BattleMenumag = new Menu();
  BattleMenumag.font         = Font;
  BattleMenumag.window_style = WindowStyle;
  BattleMenumag.arrow        = Arrow;
  if (Player.active == "Player1")
  {
    if (Playerwmagic.cure == true)
    {
    BattleMenumag.addItem("Cure", BattleSpecialMageCure);
    }
    if (Playerwmagic.peep == true)
    {
    BattleMenumag.addItem("Peep", BattleSpecialMagePeep);
    }
    if (Playerwmagic.light == true)
    {
    BattleMenumag.addItem("Light", BattleSpecialMageLight);
    }
    if (Playerwmagic.curse == true)
    {
    BattleMenumag.addItem("Curse", BattleSpecialMageCurse);
    }    
    if (Playerwmagic.sleep == true)
    {
    BattleMenumag.addItem("Sleep", BattleSpecialMageSleep);
    }
    if (Playerwmagic.life1 == true)
    {
    BattleMenumag.addItem("Life", BattleSpecialMageLife);
    }
    if (Playerwmagic.cure2 == true)
    {
    BattleMenumag.addItem("Cure 2", BattleSpecialMageCure2);
    }
    if (Playerwmagic.regain == true)
    {
    BattleMenumag.addItem("Regain", BattleSpecialMageRegain);
    }
    if (Playerwmagic.powerup == true)
    {
    BattleMenumag.addItem("Power-Up", BattleSpecialMagePowerup);
    }
    if (Playerwmagic.defup == true)
    {
    BattleMenumag.addItem("Defense-Up", BattleSpecialMageDefup);
    }
    if (Playerwmagic.haste == true)
    {
    BattleMenumag.addItem("Haste", BattleSpecialMageHaste);
    }
    if (Playerwmagic.slow == true)
    {
    BattleMenumag.addItem("Slow", BattleSpecialMageSlow);
    }
    if (Playerwmagic.stop == true)
    {
    BattleMenumag.addItem("Stop", BattleSpecialMageStop);
    }
    if (Playerwmagic.cure3 == true)
    {
    BattleMenumag.addItem("Cure 3", BattleSpecialMageCure3);
    }
    if (Playerwmagic.life2 == true)
    {
    BattleMenumag.addItem("Life 2", BattleSpecialMageLife2);
    }
    if (Playerwmagic.megacure == true)
    {
    BattleMenumag.addItem("Mega-Cure", BattleSpecialMageMegaCure);
    }
    if (Playerwmagic.recover == true)
    {
    BattleMenumag.addItem("Recover", BattleSpecialMageRecover);
    }
  }  
  else if (Player.active == "Player2")
  {
    if (Player2wmagic.cure == true)
    {
    BattleMenumag.addItem("Cure", BattleSpecialMageCure);
    }
    if (Player2wmagic.peep == true)
    {
    BattleMenumag.addItem("Peep", BattleSpecialMagePeep);
    }
    if (Player2wmagic.light == true)
    {
    BattleMenumag.addItem("Light", BattleSpecialMageLight);
    }
    if (Player2wmagic.curse == true)
    {
    BattleMenumag.addItem("Curse", BattleSpecialMageCurse);
    }    
    if (Player2wmagic.sleep == true)
    {
    BattleMenumag.addItem("Sleep", BattleSpecialMageSleep);
    }
    if (Player2wmagic.life1 == true)
    {
    BattleMenumag.addItem("Life", BattleSpecialMageLife);
    }
    if (Player2wmagic.cure2 == true)
    {
    BattleMenumag.addItem("Cure 2", BattleSpecialMageCure2);
    }
    if (Player2wmagic.regain == true)
    {
    BattleMenumag.addItem("Regain", BattleSpecialMageRegain);
    }
    if (Player2wmagic.powerup == true)
    {
    BattleMenumag.addItem("Power-Up", BattleSpecialMagePowerup);
    }
    if (Player2wmagic.defup == true)
    {
    BattleMenumag.addItem("Defense-Up", BattleSpecialMageDefup);
    }
    if (Player2wmagic.haste == true)
    {
    BattleMenumag.addItem("Haste", BattleSpecialMageHaste);
    }
    if (Player2wmagic.slow == true)
    {
    BattleMenumag.addItem("Slow", BattleSpecialMageSlow);
    }
    if (Player2wmagic.stop == true)
    {
    BattleMenumag.addItem("Stop", BattleSpecialMageStop);
    }
    if (Player2wmagic.cure3 == true)
    {
    BattleMenumag.addItem("Cure 3", BattleSpecialMageCure3);
    }
    if (Player2wmagic.life2 == true)
    {
    BattleMenumag.addItem("Life 2", BattleSpecialMageLife2);
    }
    if (Player2wmagic.megacure == true)
    {
    BattleMenumag.addItem("Mega-Cure", BattleSpecialMageMegaCure);
    }
    if (Player2wmagic.recover == true)
    {
    BattleMenumag.addItem("Recover", BattleSpecialMageRecover);
    }
  }
  else if (Player.active == "Player3")
  {
    if (Player3wmagic.cure == true)
    {
    BattleMenumag.addItem("Cure", BattleSpecialMageCure);
    }
    if (Player3wmagic.peep == true)
    {
    BattleMenumag.addItem("Peep", BattleSpecialMagePeep);
    }
    if (Player3wmagic.light == true)
    {
    BattleMenumag.addItem("Light", BattleSpecialMageLight);
    }
    if (Player3wmagic.curse == true)
    {
    BattleMenumag.addItem("Curse", BattleSpecialMageCurse);
    }    
    if (Player3wmagic.sleep == true)
    {    
    BattleMenumag.addItem("Sleep", BattleSpecialMageSleep);
    }
    if (Player3wmagic.life1 == true)
    {
    BattleMenumag.addItem("Life", BattleSpecialMageLife);
    }
    if (Player3wmagic.cure2 == true)
    {
    BattleMenumag.addItem("Cure 2", BattleSpecialMageCure2);
    }
    if (Player3wmagic.regain == true)
    {
    BattleMenumag.addItem("Regain", BattleSpecialMageRegain);
    }
    if (Player3wmagic.powerup == true)
    {
    BattleMenumag.addItem("Power-Up", BattleSpecialMagePowerup);
    }
    if (Player3wmagic.defup == true)
    {
    BattleMenumag.addItem("Defense-Up", BattleSpecialMageDefup);
    }
    if (Player3wmagic.haste == true)
    {
    BattleMenumag.addItem("Haste", BattleSpecialMageHaste);
    }
    if (Player3wmagic.slow == true)
    {
    BattleMenumag.addItem("Slow", BattleSpecialMageSlow);
    }
    if (Player3wmagic.stop == true)
    {
    BattleMenumag.addItem("Stop", BattleSpecialMageStop);
    }
    if (Player3wmagic.cure3 == true)
    {
    BattleMenumag.addItem("Cure 3", BattleSpecialMageCure3);
    }
    if (Player3wmagic.life2 == true)
    {
    BattleMenumag.addItem("Life 2", BattleSpecialMageLife2);
    }
    if (Player3wmagic.megacure == true)
    {
    BattleMenumag.addItem("Mega-Cure", BattleSpecialMageMegaCure);
    }
    if (Player3wmagic.recover == true)
    {
    BattleMenumag.addItem("Recover", BattleSpecialMageRecover);
    }    
  }  
  BattleMenumag.addItem("Cancel", GoToActivePlayer);
  BattleMenumag.execute(5, 355, 235, 120);
}

function BattleSpecialMageCure()
{
CheckMp("Lv1");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Cure"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialMagePeep()
{
CheckMp("Lv1");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Peep"
  BattleSpecialMageWEtarget()
  }
}
function BattleSpecialMageLight()
{
CheckMp("Lv1.5");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Light";
  Player.attacktype = "Holy";
  BattleSpecialMageWEtarget();
  }
}
function BattleSpecialMageCurse()
{
CheckMp("Lv2");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Curse"
  BattleSpecialMageWEtarget()
  }
}
function BattleSpecialMageSleep()
{
CheckMp("Lv1.5");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Sleep"
  BattleSpecialMageWEtarget()
  }
}
function BattleSpecialMageLife()
{
CheckMp("Lv3");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Life"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialMageCure2()
{
CheckMp("Lv2.5");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Cure 2"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialMageRegain()
{
CheckMp("Lv2.5");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Regain"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialMagePowerup()
{
CheckMp("Lv2");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Power-Up"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialMageDefup()
{
CheckMp("Lv2");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Defense-Up"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialMageHaste()
{
CheckMp("Lv2");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Haste"
  BattleSpecialMageWtarget()
  }
}
function BattleSpecialRangerEvade()
{
CheckMp("Lv2");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Evade-Up"
  BattleSpecialMageWtarget()
  }
}

function BattleSpecialMageSlow()
{
CheckMp("Lv2");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Slow"
  BattleSpecialMageWEtarget()
  }
}
function BattleSpecialMageStop()
{
CheckMp("Lv3");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Stop"
  BattleSpecialMageWEtarget()
  }
}
function BattleSpecialMageCure3()
{
CheckMp("Lv3.5");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Cure 3"
  BattleSpecialMageWhiteuseP();
  }
}
function BattleSpecialMageLife2()
{
CheckMp("Lv5");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Life 2"
  BattleSpecialMageWtarget()
  }
}

function BattleSpecialMageMegaCure()
{
CheckMp("Lv6");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Mega-Cure"
  BattleSpecialMageWhiteuseP();
  }
}
function BattleSpecialMageRecover()
{
CheckMp("Lv7");
  if (Player.needmp > Player.actmp)
  {
  Talk_Window("You don't have enough Mp!", "blank.png");
  GoToActivePlayer();
  }
  else
  {    
  Player.temp = "Recover"
  BattleSpecialMageWhiteuseP();
  }
}





function BattleSpecialMageWtarget()
{
Player.BPMenuTemp = true;
RenderMap();

  BattleName(); 
  DrawPlayerStats();
  
  var BattleMenuItem = new BMenu();
  BattleMenuItem.font         = Font;
  BattleMenuItem.window_style = WindowStyle;
  BattleMenuItem.arrow        = Arrow;

  BattleMenuItem.addItem(Player.name, BattleSpecialMageWP1);
  if (Player2.pres == true)
  {
  BattleMenuItem.addItem(Player2.name, BattleSpecialMageWP2);
  }
  if (Player3.pres == true)
  {
  BattleMenuItem.addItem(Player3.name, BattleSpecialMageWP3);
  }
  BattleMenuItem.addItem("Cancel", GoToActivePlayer);  
  BattleMenuItem.execute(5, 355, 235, 120);
}
function BattleSpecialMageWP1()
{
Player.playertemp = "Player1";
BattleSpecialMageWhiteuseP();
}
function BattleSpecialMageWP2()
{
Player.playertemp = "Player2";
BattleSpecialMageWhiteuseP();
}
function BattleSpecialMageWP3()
{
Player.playertemp = "Player3";
BattleSpecialMageWhiteuseP();
}
function BattleSpecialMageWEtarget()
{
Player.BMenuTemp = true;
RenderMap();

  BattleName(); 
  DrawPlayerStats();
  
  var BattleMenuItem = new BMenu();
  BattleMenuItem.font         = Font;
  BattleMenuItem.window_style = WindowStyle;
  BattleMenuItem.arrow        = Arrow;
  if (Monster1.hp > 0)
  {
  BattleMenuItem.addItem(Monster1.name, BattleSpecialMageWM1);
  }
  if (Monster2.hp > 0)
  {
  BattleMenuItem.addItem(Monster2.name, BattleSpecialMageWM2);
  }
  if (Monster3.hp > 0)
  {
  BattleMenuItem.addItem(Monster3.name, BattleSpecialMageWM3);
  }
  if (Monster4.hp > 0)
  {
  BattleMenuItem.addItem(Monster4.name, BattleSpecialMageWM4);
  }

  BattleMenuItem.addItem("Cancel", GoToActivePlayer);  
  BattleMenuItem.execute(5, 355, 235, 120);
}
function BattleSpecialMageWM1()
{
Player.playertemp = "Monster1";
Player.mtarget = "Monster1";
BattleSpecialMageWhiteuseP();
}
function BattleSpecialMageWM2()
{
Player.playertemp = "Monster2";
Player.mtarget = "Monster2";
BattleSpecialMageWhiteuseP();
}
function BattleSpecialMageWM3()
{
Player.playertemp = "Monster3";
Player.mtarget = "Monster3";
BattleSpecialMageWhiteuseP();
}
function BattleSpecialMageWM4()
{
Player.playertemp = "Monster4";
Player.mtarget = "Monster4";
BattleSpecialMageWhiteuseP();
}

function BattleSpecialMageWhiteuseP()
{
Player.mathtemp = Math.random()/5 + 0.9;

  if (Player.active == "Player1")
  {
    if (Player.APlate == true)
    {
    Player.mathtemp = Player.mathtemp*1.5;
    }
  }
  else if (Player.active == "Player2")
  {
    if (Player2.APlate == true)
    {
    Player.mathtemp = Player.mathtemp*1.5;
    }
  }
  else if (Player.active == "Player3")
  {
    if (Player3.APlate == true)
    {
    Player.mathtemp = Player.mathtemp*1.5;
    }
  }

GetMagStats()
  if (Player.temp == "Cure")
  {
  RenderMap();
  Player.attackdamage = Math.floor(Player.mattacktemp*Player.mathtemp);    
  ReduceMp("Lv1");
  HealPlayerTarget();
  }
  if (Player.temp == "Peep")
  {
  RenderMap();
  ReduceMp("Lv1")
  CastPeep();
  }
  if (Player.temp == "Sleep")
  {
  ReduceMp("Lv1.5")
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp + "... Success!");
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastSleep();  
  }
  if (Player.temp == "Light")
  {
  Player.attackdamage = Math.floor(Player.mathtemp*Player.mattacktemp*1.2)
  ReduceMp("Lv1.5");
  HurtMonster(Player.attackdamage);
  }
  if (Player.temp == "Curse")
  {
  ReduceMp("Lv2");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastCurse();  
  }
  if (Player.temp == "Life")
  {
  CheckLifeStatTarget();
  ReduceMp("Lv3")
    if (Player.temp4 == "true")   
    {
    Player.attackdamage = Player.hptemp;
    HealPlayerTarget();
    }
    else
    {
    Player.attackdamage = 0
    HealPlayerTarget();
    }
  }
  if (Player.temp == "Cure 2")
  {
  Player.attackdamage = Math.floor(Player.mattacktemp*Player.mathtemp*4);    
  ReduceMp("Lv2.5");
  HealPlayerTarget();
  }
  if (Player.temp == "Regain")
  {
  ReduceMp("Lv2.5");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastRegain();
  }
  if (Player.temp == "Power-Up")
  {
  ReduceMp("Lv2");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastPowerup();
  }
  if (Player.temp == "Defense-Up")
  {
  ReduceMp("Lv2");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastDefup();
  }
  if (Player.temp == "Haste")
  {
  ReduceMp("Lv2");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastHaste();
  }
  if (Player.temp == "Evade-Up")
  {
  ReduceMp("Lv2");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastHaste();
  }
  if (Player.temp == "Slow")
  {
  ReduceMp("Lv2");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastSlow();  
  }
  if (Player.temp == "Stop")
  {
  ReduceMp("Lv3");
  RenderMap();
  CastStop();  
  }
  if (Player.temp == "Cure 3")
  {
  Player.attackdamage = Math.floor(Player.mattacktemp*Player.mathtemp*7);    
  ReduceMp("Lv3.5");
  HealAllPlayerTarget();
  }
  if (Player.temp == "Life 2")
  {
  CheckLifeStatTarget();
  ReduceMp("Lv5")
    if (Player.temp4 == "true")   
    {
    Player.attackdamage = Player.hptemp;
    HealPlayerTarget();
    }
    else
    {
    Player.attackdamage = 0
    HealPlayerTarget();
    }
  }
  if (Player.temp == "Mega-Cure")
  {
  Player.attackdamage = 9000;    
  ReduceMp("Lv6");
  HealAllPlayerTarget();
  }
  if (Player.temp == "Recover")
  {
  ReduceMp("Lv7");
  CastRecover();
  }
  if (Player.temp == Player.cmagic.hold)
  {
  ReduceMp("Lv2");
  RenderMap();
  CastHold();  
  }
  if (Player.temp == Player.cmagic.anglicray)
  {
  Player.attackdamage = Math.floor(Player.mathtemp*Player.mattacktemp*25)
  ReduceMp("Lv5");
  HurtMonster(Player.attackdamage);
  BattleMenu_Itemused();
  }
  if (Player.temp == Player.cmagic.mpregain)
  {
  ReduceMp("Lv5");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastMpregain();
  }
  if (Player.temp == Player.cmagic.multiup)
  {
  ReduceMp("Lv3.5");
  RenderMap();
  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, Player.temp);
  BattleName(); 
  DrawPlayerStats();
  FlipScreen();
  Delay(500);
  CastMultiup();  
  }
}

    
/*        

  Player.attackdamage = Math.floor(Player.mattacktemp*(Math.random/5 + 0.9));    
  ReduceMp("Lv3");
  HealPlayerTarget();
  }

*/


function CheckLifeStatTarget()
{
  if (Player.playertemp == "Player1")
  {
    if (Player.hp <= 0)
    {
    Player.temp4 = "true";
      if (Player.temp == "Life")
      {
      Player.hptemp = Math.floor(Player.maxhp/5);
      }
      else
      {
      Player.hptemp = Player.maxhp;
      }
    Player.playername = "main character";
    }
    else
    {
    Player.temp4 = "none"
    }
  }
  if (Player.playertemp == "Player2")
  {
    if (Player2.hp <= 0)
    {
    Player.temp4 = "true";

      if (Player.temp == "Life")
      {
      Player.hptemp = Math.floor(Player2.maxhp/5);
      }
      else
      {
      Player.hptemp = Player2.maxhp;
      }

    Player.playername = "Player2";
    }
    else
    {
    Player.temp4 = "none"
    }
  }
  if (Player.playertemp == "Player3")
  {
    if (Player3.hp <= 0)
    {
    Player.temp4 = "true";

      if (Player.temp == "Life")
      {
      Player.hptemp = Math.floor(Player3.maxhp/5);
      }
      else
      {
      Player.hptemp = Player3.maxhp;
      }

    Player.playername = "Player3";
    }
    else
    {
    Player.temp4 = "none"
    }
  }
}  
function CastPeep()
{
  if (Player.playertemp == "Monster1")
  {
  RenderMap() 
  WindowStyle.drawWindow (25, 380, 590, 80);//25, 330, 590, 130
  Font.drawTextBox (75, 400, 525, 60, 5, Monster1.name + " - Hp: " + Monster1.hp + "/" + Monster1.maxhp + " Mp: " + Monster1.mp + "/" + Monster1.maxmp);//75, 380, 525, 100, 5
  Font.drawTextBox (75, 410, 525, 60, 5, "Weakness: " + Monster1.weak + " Resistant: " + Monster1.strong + " Immune: " + Monster1.immune + " Absorb: " + Monster1.absorb);//75, 380, 525, 100, 5
  FlipScreen();
  eatKey()
  while (IsKeyPressed(KEY_SPACE) == false) 
  {Delay(100);}
  {GetKey()}

  }  
  else if (Player.playertemp == "Monster2")
  {
  RenderMap() 
  WindowStyle.drawWindow (25, 380, 590, 80);//25, 330, 590, 130
  Font.drawTextBox (75, 400, 525, 60, 5, Monster2.name + " - Hp: " + Monster2.hp + "/" + Monster2.maxhp + " Mp: " + Monster2.mp + "/" + Monster2.maxmp);//75, 380, 525, 100, 5
  Font.drawTextBox (75, 410, 525, 60, 5, "Weakness: " + Monster2.weak + " Resistant: " + Monster2.strong + " Immune: " + Monster2.immune + " Absorb: " + Monster2.absorb);//75, 380, 525, 100, 5
  FlipScreen();
  eatKey()
  while (IsKeyPressed(KEY_SPACE) == false) 
  {Delay(100);}
  {GetKey()}

  }  
  else if (Player.playertemp == "Monster3")
  {
  RenderMap() 
  WindowStyle.drawWindow (25, 380, 590, 80);//25, 330, 590, 130
  Font.drawTextBox (75, 400, 525, 60, 5, Monster3.name + " - Hp: " + Monster3.hp + "/" + Monster3.maxhp + " Mp: " + Monster3.mp + "/" + Monster3.maxmp);//75, 380, 525, 100, 5
  Font.drawTextBox (75, 410, 525, 60, 5, "Weakness: " + Monster3.weak + " Resistant: " + Monster3.strong + " Immune: " + Monster3.immune + " Absorb: " + Monster3.absorb);//75, 380, 525, 100, 5
  FlipScreen();
  eatKey()
  while (IsKeyPressed(KEY_SPACE) == false) 
  {Delay(100);}
  {GetKey()}

  }  
  else if (Player.playertemp == "Monster4")
  {
  RenderMap() 
  WindowStyle.drawWindow (25, 380, 590, 80);//25, 330, 590, 130
  Font.drawTextBox (75, 400, 525, 60, 5, Monster4.name + " - Hp: " + Monster4.hp + "/" + Monster4.maxhp + " Mp: " + Monster4.mp + "/" + Monster4.maxmp);//75, 380, 525, 100, 5
  Font.drawTextBox (75, 410, 525, 60, 5, "Weakness: " + Monster4.weak + " Resistant: " + Monster4.strong + " Immune: " + Monster4.immune + " Absorb: " + Monster4.absorb);//75, 380, 525, 100, 5
  FlipScreen();
  eatKey()
  while (IsKeyPressed(KEY_SPACE) == false) 
  {Delay(100);}
  {GetKey()}

  }
BattleMenu_Itemused();
}
function CastCurse()
{
  if (Player.playertemp == "Monster1")
  {
  Monster1.evade = Math.floor(Monster1.agi/7.5);
  Monster1.attack = Math.floor(Monster1.str*0.75);
  Monster1.defence = Math.floor(Monster1.vit*0.75);
  }
  else if (Player.playertemp == "Monster2")
  {
  Monster2.evade = Math.floor(Monster2.agi/7.5);
  Monster2.attack = Math.floor(Monster2.str*0.75);
  Monster2.defence = Math.floor(Monster2.vit*0.75);
  }
  else if (Player.playertemp == "Monster3")
  {
  Monster3.evade = Math.floor(Monster3.agi/7.5);
  Monster3.attack = Math.floor(Monster3.str*0.75);
  Monster3.defence = Math.floor(Monster3.vit*0.75);
  }
  else if (Player.playertemp == "Monster4")
  {
  Monster4.evade = Math.floor(Monster4.agi/7.5);
  Monster4.attack = Math.floor(Monster4.str*0.75);
  Monster4.defence = Math.floor(Monster4.vit*0.75);
  }
BattleMenu_Itemused();
}
function CastSleep()
{
Battle.m = Math.random()/2 + 0.7;
  if (Player.playertemp == "Monster1")
  {
    if (Battle.m*Player.mluck/Monster1.luck > 1)
    {
    Monster1.stun = 3;
    Player.temp = "Sleep ... Success!"
    }
    else
    {
    Player.temp = "Sleep... Failed."
    }
  }
  if (Player.playertemp == "Monster2")
  {
    if (Battle.m*Player.mluck/Monster2.luck > 1)
    {
    Monster2.stun = 3;
    Player.temp = "Sleep... Success!"
    }
    else
    {
    Player.temp = "Sleep... Failed."
    }
  }  
  if (Player.playertemp == "Monster3")
  {
    if (Battle.m*Player.mluck/Monster3.luck > 1)
    {
    Monster3.stun = 3;
    Player.temp = "Sleep... Success!"
    }
    else
    {
    Player.temp = "Sleep... Failed."
    }
  }
  if (Player.playertemp == "Monster4")
  {
    if (Battle.m*Player.mluck/Monster4.luck > 1)
    {
    Monster4.stun = 3;
    Player.temp = "Sleep... Success!"
    }
    else
    {
    Player.temp = "Sleep... Failed."
    }
  }
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, Player.temp);
BattleName(); 
DrawPlayerStats();
FlipScreen();
Delay(500);
BattleMenu_Itemused();
}

function CastRegain()
{
  if (Player.playertemp == "Player1")
  {
  Player.modreg = true;
  }
  else if (Player.playertemp == "Player2")
  {
  Player2.modreg = true;
  }
  else if (Player.playertemp == "Player3")
  {
  Player3.modreg = true;
  }
BattleMenu_Itemused();
}
function CastPowerup()
{
  if (Player.playertemp == "Player1")
  {
  Player.attack = (Player.str + Player.weaponeffect)*2
  }
  else if (Player.playertemp == "Player2")
  {
  Player2.attack = (Player2.str + Player2.weaponeffect)*2
  }
  else if (Player.playertemp == "Player3")
  {
  Player3.attack = (Player3.str + Player3.weaponeffect)*2
  }
BattleMenu_Itemused();
}
function CastDefup()
{
  if (Player.playertemp == "Player1")
  {
  Player.attack = (Player.vit + Player.armoureffect)*2
  }
  else if (Player.playertemp == "Player2")
  {
  Player2.defence = (Player2.vit + Player2.armoureffect)*2
  }
  else if (Player.playertemp == "Player3")
  {
  Player3.defence = (Player3.vit + Player3.armoureffect)*2
  }
BattleMenu_Itemused();
}

function CastHaste()
{
  if (Player.playertemp == "Player1")
  {
  Player.evade = Math.floor(Player.agi/2.5);
  }
  else if (Player.playertemp == "Player2")
  {
  Player2.evade = Math.floor(Player2.agi/2.5);
  }
  else if (Player.playertemp == "Player3")
  {
  Player3.evade = Math.floor(Player3.agi/2.5);
  }
BattleMenu_Itemused();
}
function CastSlow()
{
  if (Player.playertemp == "Monster1")
  {
  Monster1.evade = Math.floor(Monster1.agi/10);
  }
  else if (Player.playertemp == "Monster2")
  {
  Monster2.evade = Math.floor(Monster2.agi/10);
  }
  else if (Player.playertemp == "Monster3")
  {
  Monster3.evade = Math.floor(Monster3.agi/10);
  }
  else if (Player.playertemp == "Monster4")
  {
  Monster4.evade = Math.floor(Monster4.agi/10);
  }
BattleMenu_Itemused();
}
function CastStop()
{
Battle.math = Math.random()/2 + 0.7;
  if (Player.playertemp == "Monster1")
  {
    if (Battle.math*Player.mluck/Monster1.luck > 1)
    {
    Monster1.stun = 5;
    Player.temp = "Stop... Success!"
    }
    else
    {
    Player.temp = "Stop... Failed."
    }
  }
  if (Player.playertemp == "Monster2")
  {
    if (Battle.math*Player.mluck/Monster2.luck > 1)
    {
    Monster2.stun = 5;
    Player.temp = "Stop... Success!"
    }
    else
    {
    Player.temp = "Stop... Failed."
    }
  }  
  if (Player.playertemp == "Monster3")
  {
    if (Battle.math*Player.mluck/Monster3.luck > 1)
    {
    Monster3.stun = 5;
    Player.temp = "Stop... Success!"
    }
    else
    {
    Player.temp = "Stop... Failed."
    }
  }
  if (Player.playertemp == "Monster4")
  {
    if (Battle.math*Player.mluck/Monster4.luck > 1)
    {
    Monster4.stun = 5;
    Player.temp = "Stop... Success!"
    }
    else
    {
    Player.temp = "Stop... Failed."
    }
  }    

WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, Player.temp);
BattleName(); 
DrawPlayerStats();
FlipScreen();
Delay(500);
BattleMenu_Itemused();
}
function CastMpregain()
{
  if (Player.playertemp == "Player1")
  {
  Player.modmpreg = true;
  }
  else if (Player.playertemp == "Player2")
  {
  Player2.modmpreg = true;
  }
  else if (Player.playertemp == "Player3")
  {
  Player3.modmpreg = true;
  }
BattleMenu_Itemused();
}
function CastMultiup()
{
  if (Player.playertemp == "Player1")
  {
  Player.attack = (Player.str + Player.weaponeffect)*2
  Player.defence = (Player.vit + Player.armoureffect)*2
  Player.evade = Math.floor(Player.agi/2.5);
  }
  else if (Player.playertemp == "Player2")
  {
  Player2.attack = (Player2.str + Player2.weaponeffect)*2
  Player2.defence = (Player2.vit + Player2.armoureffect)*2
  Player2.evade = Math.floor(Player2.agi/2.5);
  }
  else if (Player.playertemp == "Player3")
  {
  Player3.attack = (Player3.str + Player3.weaponeffect)*2
  Player3.defence = (Player3.vit + Player3.armoureffect)*2
  Player3.evade = Math.floor(Player3.agi/2.5);
  }
BattleMenu_Itemused();
}
function CastHold()
{
Battle.m = Math.random()/2 + 1.2;
  if (Player.playertemp == "Monster1")
  {
    if (Battle.m*Player.mluck/Monster1.luck > 1)
    {
    Monster1.stun = 2;
    Player.temp = "Hold ... Success!"
    }
    else
    {
    Player.temp = "Hold... Failed."
    }
  }
  if (Player.playertemp == "Monster2")
  {
    if (Battle.m*Player.mluck/Monster2.luck > 1)
    {
    Monster2.stun = 2;
    Player.temp = "Hold... Success!"
    }
    else
    {
    Player.temp = "Hold... Failed."
    }
  }  
  if (Player.playertemp == "Monster3")
  {
    if (Battle.m*Player.mluck/Monster3.luck > 1)
    {
    Monster3.stun = 2;
    Player.temp = "Hold... Success!"
    }
    else
    {
    Player.temp = "Hold... Failed."
    }
  }
  if (Player.playertemp == "Monster4")
  {
    if (Battle.m*Player.mluck/Monster4.luck > 1)
    {
    Monster4.stun = 2;
    Player.temp = "Hold... Success!"
    }
    else
    {
    Player.temp = "Hold... Failed."
    }
  }
WindowStyle.drawWindow(5, 5, 235, 12);
Font.drawText(7, 7, Player.temp);
BattleName(); 
DrawPlayerStats();
FlipScreen();
Delay(500);
BattleMenu_Itemused();
}
function CastRecover()
{
RenderMap();
  Player.hp = Player.maxhp;
  HpFont.drawTextBox (Player.P1x, Player.P1y, 500, 100, 5, Player.maxhp);
  if (Player2.pres == true)
  {
  Player2.hp = Player2.maxhp;
  HpFont.drawTextBox (Player.P2x, Player.P2y, 500, 100, 5, Player2.maxhp);
  }
  if (Player3.pres == true)
  {
  Player3.hp = Player3.maxhp;
  HpFont.drawTextBox (Player.P3x, Player.P3y, 500, 100, 5, Player3.maxhp);
  }

  WindowStyle.drawWindow(5, 5, 235, 12);
  Font.drawText(7, 7, "Recover");
  DrawPlayerStats();
  BattleName();
  FlipScreen();
  Delay(1500);
  SetPersonDirection("main character", 6);  
  if (Player2.pres == true)
  {
  SetPersonDirection("Player2", 6);  
  }
  if (Player3.pres == true)
  {
  SetPersonDirection("Player3", 6);
  }
BattleMenu_Itemused();
}  
